<?php
/**
 * The MIT License
 *
 * Copyright (c) <year> <copyright holders>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @author Damiano Ciarla
 * @package plugin
 * @subpackage exception
 * @name Router
 */
class Router_Exception extends Exception
{
	/**
	 * Nessuna route definita
	 */
	const NO_ROUTES_DEFINED = 1;

	/**
	 * La route non è presente
	 */
	const ROUTES_NOT_FOUND = 2;

	/**
	 * È necessario definire i parametri per la route
	 */
	const PARAMS_CAN_NOT_BE_NULL = 3;

	/**
	 * Il numero dei parametri non corrisponde al numero dei parametri della route
	 */
	const WRONG_NUMBER_OF_PARAMETERS = 4;

	/**
	 * Il parametro non è stato trovato tra quelli passati nel metodo
	 */
	const REQUIRED_PARAM_NOT_FOUND = 5;

	/**
	 * Il parametro non è stato trovato tra quelli passati nel metodo
	 */
	const SOME_PARAMETERS_ARE_NOT_PRESENT_INTO_ROUTE_PARAMS = 6;

	/**
	 * L'ordine dei parametri opzionali della route non è stato rispettato
	 */
	const INCORRECT_ORDER_FOR_OPTIONAL_PARAMETERS = 7;

	public function __construct($params, $code)
	{
		switch($code)
		{
			case self::NO_ROUTES_DEFINED :
				$message = "No routes defined";
				break;

			case self::ROUTES_NOT_FOUND :
				$message = sprintf("'%s' route not found into routes list", $params);
				break;

			case self::PARAMS_CAN_NOT_BE_NULL :
				$message = "The parameter list can not be empty";
				break;

			case self::WRONG_NUMBER_OF_PARAMETERS :
				$message = "The number of parameters does not match the number of parameters of the route";
				break;

			case self::REQUIRED_PARAM_NOT_FOUND :
				$message = sprintf("The param '%s' not found into list params", $params);
				break;

			case self::SOME_PARAMETERS_ARE_NOT_PRESENT_INTO_ROUTE_PARAMS :
				$message = sprintf("One or more parameters (%s) were not found in the parameter list of the route", $params);
				break;

			case self::INCORRECT_ORDER_FOR_OPTIONAL_PARAMETERS :
				$message = "Incorrect order of route parameters";
				break;
		}

		parent::__construct($message, $code);
	}
}
?>